package net.xiangcaowuyu.springcloud.alibaba.seata.controller;

import lombok.extern.slf4j.Slf4j;
import net.xiangcaowuyu.springcloud.alibaba.seata.service.IAccountService;
import net.xiangcaowuyu.springcloud.entites.CommonResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * 博客：https://www.xiangcaowuyu.net
 * Description:
 *
 * @Author: 香草物语
 * DateTime: 2021-07-25 21:19
 */
@RestController
@Slf4j
@RequestMapping("/account")
public class AccountController {

    @Resource
    private IAccountService accountService;

    @PostMapping("/decrease")
    public CommonResult decrease(@RequestParam("userId") Long userId, @RequestParam("money") BigDecimal money) {
        accountService.decrease(userId, money);
        return new CommonResult(200, "账户扣减成功");
    }

}
